package com.itheima01;

import java.util.concurrent.ArrayBlockingQueue;

public class Test01 {
    public static void main(String[] args) {
        ArrayBlockingQueue<String> queue=new ArrayBlockingQueue<>(10);

        new Thread(()->{
            while (true) {
                try {
                    queue.put("汉堡包");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("厨师做了一个汉堡包"+queue.size());
            }
        }).start();
        new Thread(()->{
            while (true) {
                try {
                    System.out.println("消费者获取到一个"+queue.take()+queue.size());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }
}
